<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>站内信编辑</title>
<#include "/WEB-INF/content/module-edit.html">
<script type="text/javascript">
var sysStatus = [
    {"id":"0","text":"正常"},
    {"id":"1","text":"禁用"}
];
var typeTree=[
<#list map.typeTree as item>
   	<#if item_has_next>
   		{"id":"${item.id}","text":"${item.text}",
"children":[
<#list item.children as ite>
	<#if ite_has_next>
 		{"id":"${ite.id}","text":"${ite.text}"},  			
	<#else>
		{"id":"${ite.id}","text":"${ite.text}"}
	</#if>
</#list>
]},
   	<#else>
   		{"id":"${item.id}","text":"${item.text}",
   		"children":[
   		<#list item.children as ite>
   			<#if ite_has_next>
   		 		{"id":"${ite.id}","text":"${ite.text}"},  			
   			<#else>
   				{"id":"${ite.id}","text":"${ite.text}"}
   			</#if>
   		</#list>
   		]}
   	</#if>
</#list>
];
var idtype=[
	{"id":"0","text":"身份证"},
	{"id":"1","text":"驾驶证"}
];
var sex=[
   	{"id":"0","text":"未设置"},
  	{"id":"1","text":"男"},
  	{"id":"1","text":"女"}];
$(function() {
  	$("#status").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
  		data:sysStatus
  	}); 
  	$("#upload").click(function(){
  		$.ajax({
 			url:"search",
	  		async:false,
	  		type:"POST",
	  		data:{
	  			mobile:$("#searchItem").val(),
	  		},
	  		success:function(data){
	  			if(data.state==0){
	  				top.showMsg("用户未找到或者已办理会员卡");
	  			}else{
	  				var s=data.state.split("_");
	  				$("#name").val(s[1]);
	  				$("#uid").val(s[0]);
	  			}
	  		}
  		})
  	});
  	$("#parent").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
        required:true,
  		data:typeTree,
  		onChange:function(data){
  			for(var i in typeTree){
  				if(typeTree[i].id==data){
  					$("#mtid").combobox({
  				  		valueField : 'id',
  				  		textField : 'text',
  				  		editable:false,
  				        panelHeight:'auto',
  				        required:true,
  				        value:"",
  				  		data:typeTree[i].children
  					});
  				}
  			}
  		}
  	});	  
    <#if object.mtid?exists&&object.mtid!="">
    var sub;
    var parent=$("#parent").val();
    for(var i in typeTree){
    	if(typeTree[i].id==parent){
    		sub=typeTree[i].children;
    	}
    }
	$("#mtid").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
        required:true,
        data:sub
	});    
	<#else>
	$("#mtid").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
        required:true
	}); 
	</#if>
	$("#idtype").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
        data:idtype		
	});
	$("#sex").combobox({
  		valueField : 'id',
  		textField : 'text',
  		editable:false,
        panelHeight:'auto',
        data:sex	
	});
	 <#if object.mtid?exists&&object.mtid!="">
	 	$("#balane").numberbox({min:-${object.balane!},precision:2});
	 </#if>
 });
</script>
<style>
.input-width{
	width: 95%;
}
</style>
 
</head>
<body class="easyui-layout">
	<div region="north" id="toolbar" style="background-color: #eee; padding: 5px; overflow: hidden;" border="false">
		<#if object.mid?exists&&object.mid!="">
			<@auth code="membershipcard:card:update">
				<a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-add" style="border: 1px solid #ccc" onclick="javascript:save()">保存</a>
			</@auth>
		<#else>
			<@auth code="membershipcard:card:create">
				<a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-add" style="border: 1px solid #ccc" onclick="javascript:save()">保存</a>
			</@auth>
		</#if>
		<a href="javascript:void(0);" class="easyui-linkbutton" plain="true" iconCls="icon-edit" style="border: 1px solid #ccc" onclick="javascript:cancel()">关闭</a>
	</div>
	<div region="center">
		<div id="p" class="easyui-panel" style="background: #fafafa; padding: 10px" fit="true" toolbar="#toolbar">
			<form id="form" method="post">
				<input id="_id" name="mid" type="hidden" value="${(object.mid)!}">
				<table class="form" cellspacing="0" style="width: 100%">
					<tbody style="border: 1px solid #ccc">
					<#if object.mid?exists&&object.mid!="">
						<tr>
							<td class="label">余额：</td>
							<td><input value="${object.balane!}" name="balane" readonly="readonly"/></td>
							<td class="validate"></td>	
							<td class="label">充值/退款：</td>
							<td><input id="balane" name="recharge" value="0"/></td>
							<td class="validate"></td>							
						</tr>
						<tr>
							<td class="label">会员卡类型：</td>
							<td>
								<input id="parent" value="${(map.typeparent)!}"/>
								<input id="mtid" name="mtid" value="${(object.mtid)!}"/>
								<input type="hidden" name="uid" value="${(object.uid)!}"/>
							</td>
							<td class="validate"></td>								
						</tr>
					<#else>
						<tr>
							<td class="label">所属用户：</td>
							<td>
								<input id="searchItem" placeholder="请输入手机号码"/><a href="#" class="easyui-linkbutton" id="upload">搜索</a>
								&nbsp;&nbsp;<input id="name" class="easyui-validatebox" readonly="readonly" required="true"/></td>
								<input id="uid" type="hidden" name="uid"/>
							<td class="validate">*</td>	
							<td class="label">会员卡类型：</td>
							<td colspan="4">
								<input id="parent"/>
								<input id="mtid" name="mtid"/>
							</td>
							<td class="validate">*</td>								
						</tr>	
					</#if>		
						<tr>
							<td class="label">证件类型：</td>
							<td>
								<input id="idtype" name="idtype" value="${object.idtype!0}"/>
							</td>
							<td class="validate"></td>	
							<td class="label">证件号码：</td>
							<td>
								<input id="idcard" name="idcard" value="${object.idcard!}"/>
							</td>
							<td class="validate"></td>															
						</tr>	
						<tr>
							<td class="label">性别：</td>
							<td>
								<input id="sex" name="sex" value="${object.sex!0}"/>
							</td>
							<td class="validate"></td>	
							<td class="label">出生日期：</td>
							<td>
								<input id="birthday" class="easyui-datebox" name="birthday" value="${object.birthday!}"/>
							</td>
							<td class="validate"></td>															
						</tr>
						<tr>
							<td class="label">职业：</td>
							<td>
								<input id="profession" style="width:90%;" name="profession" value="${object.profession!}"/>
							</td>
							<td class="validate"></td>	
							<td class="label">家庭住址：</td>
							<td>
								<input id="address" name="address" style="width:90%;" value="${object.address!}"/>
							</td>
							<td class="validate"></td>															
						</tr>																			
						<tr>
							<td class="label">状态：</td>
							<td>
								<input id="status" name="status" value="${object.status!0}"/>
							</td>
							<td class="validate"></td>								
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
</body>
</html>